////////////////////////////////////////////////////////////////////////////////
//
//  nino
//
////////////////////////////////////////////////////////////////////////////////

package ochart.utils.logging
{
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	public class Logger extends EventDispatcher
	{
		
		private var loggerManager:LoggerManager = LoggerManager.instance;
		public var className:String = null;
		
		public function Logger(target:IEventDispatcher=null)
		{
			super(target);
		}
		
		public static function getLogger(className:String):Logger
		{
			var logger:Logger = new Logger();
			logger.className = className;
			return logger;
		}
		
		protected function log(level:Level, message:Object):void
		{
			var log:Log = new Log(this.className, level, message, new Date());
			loggerManager.add(log);
		}
		
		public function debug(message:Object):void
		{
			log(Level.DEBUG, message);
		}
		
		public function info(message:Object):void
		{
			log(Level.INFO, message);
		}
		
		public function warn(message:Object):void
		{
			log(Level.WARN, message);
		}
		
		public function error(message:Object):void
		{
			log(Level.ERROR, message);
		}
		
		public function fatal(message:Object):void
		{
			log(Level.FATAL, message);
		}
	}
}